<?php

Database::ExecuteCreateStandardTable('master'
	,'TestString',Sql::String100
	,'TestInteger',Sql::Integer
	,'TestNullableInteger',Sql::Integer
	,'TestBoolean',Sql::Boolean
	,'TestNullableBoolean',Sql::Boolean
	);
	
class Master extends DBItem {
	public $TestString = null;
	public $TestInteger = 0;
	public $TestNullableInteger = null;
	public $TestBoolean = false;
	public $TestNullableBoolean = null;
	public static function FillMetaClass(MetaClass $c){
		$c->SetDBTableName('master');
		$c->TestString = MetaField::String();
		$c->TestInteger = MetaField::Integer();
		$c->TestNullableInteger = MetaField::NullableInteger();
		$c->TestBoolean = MetaField::Boolean();
		$c->TestNullableBoolean = MetaField::NullableBoolean();
	}
}






//
//
// Creation
//
//
Test::Begin('DBItem creation');
$x = Master::Create();
Test::Assert(0 == $x->id->AsInt());

$x2 = Master::Retrieve(0);
Test::Assert($x === $x2);

$x3 = new Master();
Test::Assert(1 == $x3->id->AsInt());

$x4 = Master::Retrieve(1);
Test::Assert(is_null($x4));


Test::Begin('DBItem save');
$x->TestString = 'test';
$x->Save();
Test::Assert('test' == Database::ExecuteScalar('SELECT TestString FROM master WHERE id='.new Sql(0))->AsString());


?>
